<template>
  <div class="wrapper">
    <!-- 楼层装修组件 -->
    <tpl ref="tpl" />
  </div>
</template>
<script>
import tpl from "@/pages/tabbar/home/views.vue";
import { ssoLogin } from "../../../api/login";
import {getUserInfo} from '../../../api/members.js'
import storage from "../../../utils/storage";

export default {
  data() {
    return {
      background: {
        backgroundColor: "#fff",
      },
    };
  },
  mounted() {
  	  let token = storage.getSSOToken();
	  console.info("token",token);
	  if(token!=null && token!== ''){
	     ssoLogin(token).then((res)=>{
			 console.info("res",res);
			 if (res.data.success) {
			   storage.setAccessToken(res.data.result.accessToken);
			   storage.setRefreshToken(res.data.result.refreshToken);
			 
			   /**
			    * 登录成功后获取个人信息
			    */
			   getUserInfo().then((user) => {
			     if (user.data.success) {
			       /**
			        * 个人信息存储到缓存userInfo中
			        */
			       storage.setUserInfo(user.data.result);
			       storage.setHasLogin(true);
			       // 登录成功
			       // uni.showToast({
			       //   title: "登录成功!",
			       //   icon: "none",
			       // });
			     } 
			   });
			 }
		 });
	  }
  },
  onPullDownRefresh() {
    this.$refs.tpl.init();

    uni.stopPullDownRefresh();
  },
  components: {
    tpl,
  },
};
</script>

<style lang="scss" scoped>
</style>
